import {
  getStorageToken,
  setStorageToken,
  removeStorageToken
} from '@/utils/store'

import { userInfo } from '@/api/user'
const state = {
  token: getStorageToken(),
  // 存储个人信息
  userInfo: {}
}
const mutations = {
  setToken(state, value) {
    state.token = value
    setStorageToken(value)
  },
  removeToken() {
    removeStorageToken()
  },
  setUserInfo(state, obj) {
    state.userInfo = obj
  }
}
const actions = {
  async ActionsGetUserInfo(context) {
    const res = await userInfo()
    context.commit('setUserInfo', res.data)
  }
}
const getters = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
